var area = new Array();
var curr = new Array(); 
var rows = 0;
var cols = 0;
var timer;

var w3c  = document.getElementById && !window.opera;
var ie45 = document.all            && !window.opera;
  
window.onload = function()
{
  if (!w3c && !ie45)
    return;
    
  area [0] = " Objective-c ";
  area [1] = "  Foundation ";
  area [2] = "     Classes ";
    
  rows = area.length;
  cols = area[0].length;
    
  for (var r = 0; r < rows; r++)
  {
    curr[r] = new Array(cols);
    
    for (var c = 0; c < cols; c++)
    {
      curr[r][c] = " ";
    }
  }
    
  var space = String.fromCharCode(160);
    
  if (w3c)
  {
    var logo = document.getElementById("logo");
      
    var table = document.createElement("table");
    
    table.setAttribute("border", 0);
    table.setAttribute("align", "default");
      
    var tbody = document.createElement("tbody");
      
    for (r = 0; r < rows; r++)
    {
      var row = document.createElement("tr");
      for (c = 0; c < cols; c++)
      {
        var col = document.createElement("td");
          
        col.setAttribute("id", "Lr"+r+"c"+c);
        col.style.fontFamily = "monospace"
          
        col.appendChild(document.createTextNode(space));
         
        row.appendChild(col);
      }
      tbody.appendChild(row);
    }

    table.appendChild(tbody);
      
    logo.appendChild(table);
  }
  else
  {
    var logo = document.all["log"];
      
    var table = '<ta' + 'ble align="default" border="0">';
      
    for (var r = 0; r < rows; r++)
    {
      table += '<t' + 'r>';
        
      for (var c = 0; c < cols; c++)
      {
        table += '<t' + 'd id="Lr' + r + 'c' + c + '">' + space + '</' + 'td>';
      }
      table += '</' + 'tr>';
    }
      
    table += '</' + 'table>';
      
    logo.innerHTML = table;       
  }
    
  timer = setInterval("update()", 100);
}
  
function update()
{
  var space = String.fromCharCode(160);
  var ready = true;
    
  for (var r = 0; r < rows; r++)
  {
    for (var c = 0; c < cols; c++)
    {
      if (curr[r][c] != area[r].charAt(c))
      {
        ready = false;
          
        ch = String.fromCharCode(32 + Math.floor(Math.random() * 94));
          
        curr[r][c] = ch;
          
        if (ch == " ")
          ch = space;
            
        if (w3c)
        {
          field = document.getElementById("Lr" + r + "c" + c);
            
          if (area[r].charAt(c) == ch)
            field.style.fontWeight = "bold";
             
          field.firstChild.nodeValue = ch;
        }
        else
        {
          field = document.all["Lr" + r + "c" + c];
            
          if (area[r].charAt(c) == ch)
            field.style.fontWeight = "bold";
              
          field.innerHTML = ch;
        }
      }
    }
  }
    
  if (ready)
    clearInterval(timer);
}
